home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 January / january_2001.iso / intercd / root / ^4Developers / VB / visbasdb / VBDB / VBDB Code / VB6 Code / Class 5 / Exercise5AD.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-12-03  |  6.6 KB  |  198 lines

  1. VERSION 5.00
  2. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  3. Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
  4. Begin VB.Form frmSQLTester 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "SQL Tester"
  7.    ClientHeight    =   3540
  8.    ClientLeft      =   45
  9.    ClientTop       =   330
  10.    ClientWidth     =   6360
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3540
  15.    ScaleWidth      =   6360
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin MSAdodcLib.Adodc datSQLTester 
  18.       Height          =   330
  19.       Left            =   4080
  20.       Top             =   3120
  21.       Width           =   2175
  22.       _ExtentX        =   3836
  23.       _ExtentY        =   582
  24.       ConnectMode     =   0
  25.       CursorLocation  =   3
  26.       IsolationLevel  =   -1
  27.       ConnectionTimeout=   15
  28.       CommandTimeout  =   30
  29.       CursorType      =   3
  30.       LockType        =   3
  31.       CommandType     =   8
  32.       CursorOptions   =   0
  33.       CacheSize       =   50
  34.       MaxRecords      =   0
  35.       BOFAction       =   0
  36.       EOFAction       =   0
  37.       ConnectStringType=   1
  38.       Appearance      =   1
  39.       BackColor       =   -2147483643
  40.       ForeColor       =   -2147483640
  41.       Orientation     =   0
  42.       Enabled         =   -1
  43.       Connect         =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Nwind.mdb"
  44.       OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\VBDB\Working\Nwind.mdb"
  45.       OLEDBFile       =   ""
  46.       DataSourceName  =   ""
  47.       OtherAttributes =   ""
  48.       UserName        =   ""
  49.       Password        =   ""
  50.       RecordSource    =   ""
  51.       Caption         =   "SQL Tester"
  52.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  53.          Name            =   "MS Sans Serif"
  54.          Size            =   8.25
  55.          Charset         =   0
  56.          Weight          =   400
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       _Version        =   393216
  62.    End
  63.    Begin MSDataGridLib.DataGrid grdSQLTester 
  64.       Bindings        =   "Exercise5AD.frx":0000
  65.       Height          =   1695
  66.       Left            =   120
  67.       TabIndex        =   4
  68.       TabStop         =   0   'False
  69.       Top             =   120
  70.       Width           =   6135
  71.       _ExtentX        =   10821
  72.       _ExtentY        =   2990
  73.       _Version        =   393216
  74.       HeadLines       =   1
  75.       RowHeight       =   15
  76.       BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  77.          Name            =   "MS Sans Serif"
  78.          Size            =   8.25
  79.          Charset         =   0
  80.          Weight          =   400
  81.          Underline       =   0   'False
  82.          Italic          =   0   'False
  83.          Strikethrough   =   0   'False
  84.       EndProperty
  85.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  86.          Name            =   "MS Sans Serif"
  87.          Size            =   8.25
  88.          Charset         =   0
  89.          Weight          =   400
  90.          Underline       =   0   'False
  91.          Italic          =   0   'False
  92.          Strikethrough   =   0   'False
  93.       EndProperty
  94.       ColumnCount     =   2
  95.       BeginProperty Column00 
  96.          DataField       =   ""
  97.          Caption         =   ""
  98.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  99.             Type            =   0
  100.             Format          =   ""
  101.             HaveTrueFalseNull=   0
  102.             FirstDayOfWeek  =   0
  103.             FirstWeekOfYear =   0
  104.             LCID            =   1033
  105.             SubFormatType   =   0
  106.          EndProperty
  107.       EndProperty
  108.       BeginProperty Column01 
  109.          DataField       =   ""
  110.          Caption         =   ""
  111.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  112.             Type            =   0
  113.             Format          =   ""
  114.             HaveTrueFalseNull=   0
  115.             FirstDayOfWeek  =   0
  116.             FirstWeekOfYear =   0
  117.             LCID            =   1033
  118.             SubFormatType   =   0
  119.          EndProperty
  120.       EndProperty
  121.       SplitCount      =   1
  122.       BeginProperty Split0 
  123.          BeginProperty Column00 
  124.          EndProperty
  125.          BeginProperty Column01 
  126.          EndProperty
  127.       EndProperty
  128.    End
  129.    Begin VB.CommandButton cmdTest 
  130.       Caption         =   "Test SQL Statement"
  131.       Height          =   495
  132.       Left            =   4080
  133.       TabIndex        =   3
  134.       TabStop         =   0   'False
  135.       Top             =   1920
  136.       Width           =   2175
  137.    End
  138.    Begin VB.TextBox txtSQLTester 
  139.       Height          =   1575
  140.       Left            =   120
  141.       MultiLine       =   -1  'True
  142.       ScrollBars      =   2  'Vertical
  143.       TabIndex        =   2
  144.       Top             =   1920
  145.       Width           =   3855
  146.    End
  147.    Begin VB.Label lblRecords 
  148.       Alignment       =   2  'Center
  149.       BackColor       =   &H00FFFFFF&
  150.       BorderStyle     =   1  'Fixed Single
  151.       Caption         =   "0"
  152.       BeginProperty Font 
  153.          Name            =   "MS Sans Serif"
  154.          Size            =   12
  155.          Charset         =   0
  156.          Weight          =   400
  157.          Underline       =   0   'False
  158.          Italic          =   0   'False
  159.          Strikethrough   =   0   'False
  160.       EndProperty
  161.       Height          =   495
  162.       Left            =   5040
  163.       TabIndex        =   1
  164.       Top             =   2520
  165.       Width           =   1215
  166.    End
  167.    Begin VB.Label Label1 
  168.       Caption         =   "Records Returned"
  169.       Height          =   495
  170.       Left            =   4080
  171.       TabIndex        =   0
  172.       Top             =   2520
  173.       Width           =   1215
  174.    End
  175. Attribute VB_Name = "frmSQLTester"
  176. Attribute VB_GlobalNameSpace = False
  177. Attribute VB_Creatable = False
  178. Attribute VB_PredeclaredId = True
  179. Attribute VB_Exposed = False
  180. Option Explicit
  181. Private Sub cmdTest_Click()
  182. 'Enable error handling
  183. On Error GoTo SQLError
  184. 'Read SQL statement and establish Recordsource
  185. datSQLTester.RecordSource = txtSQLTester.Text
  186. datSQLTester.Refresh
  187. 'Count records
  188. datSQLTester.Recordset.MoveLast
  189. datSQLTester.Recordset.MoveFirst
  190. lblRecords.Caption = datSQLTester.Recordset.RecordCount
  191. txtSQLTester.SetFocus
  192. Exit Sub
  193. 'If error occurs, report it in message box
  194. SQLError:
  195. MsgBox Error(Err.Number), vbExclamation + vbOKOnly, "SQL Error"
  196. Exit Sub
  197. End Sub
  198.